﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ghy.Soft.IBusiness;
using Ghy.Soft.Domain.Entities;
using NHibernate;
using Ghy.Soft.Data;

namespace Ghy.Soft.Business
{
    public class AdminBusiness : IAdminBusiness
    {
        AdminDao adminDao;
        CommonHelper commonHelper;

        public AdminBusiness()
        {
            adminDao = new AdminDao();
            commonHelper = new CommonHelper();
        }

        public List<Admin> GetAllAdmins()
        {
            return adminDao.GetAllAdmins();
        }

        public Admin GetAdminByUsernameAndPassword(string username, string password)
        {
            return adminDao.GetAdminByUsernameAndPassword(username, commonHelper.EncryptBySHA1(password));
        }


        public int AddNewAdmin(Admin admin)
        {
            admin.Password = commonHelper.EncryptBySHA1(admin.Password);
            return adminDao.Save(admin);
        }
    }
}
